<?php require_once("admin-header.php");
if (!(isset($_SESSION['administrator']))){
	echo "<a href='../loginpage.php'>Please Login First!</a>";
	exit(1);
}?>
<?php if(isset($_POST['do'])){
	require_once("../include/check_post_key.php");
	$from=mysql_real_escape_string($_POST['from']);
	$to=mysql_real_escape_string($_POST['to']);
	$start=intval($_POST['start']);
	$end=intval($_POST['end']);
	$sql="update `solution` set `user_id`='$to' where `user_id`='$from' and problem_id>=$start and problem_id<=$end and result=4";
	echo $sql;
	mysql_query($sql);
	echo mysql_affected_rows()." source file given!";
	
}
?>

<center><h2>代码转移（实验功能）</h2></center>

<form class="form-horizontal col-sm-6 col-sm-offset-2" action="source_give.php" method="post">
    <div class="form-group">
        <label class="col-sm-5 control-label">被克隆用户ID</label>
        <div class="col-sm-7">
        <input class="form-control" name="from" type="text"/></div>
    </div>
	<div class="form-group">
        <label class="col-sm-5 control-label">新用户ID</label>
        <div class="col-sm-7">
        <input class="form-control" name="to" type="text"/></div>
    </div>
	<div class="form-group">
        <label class="col-sm-5 control-label">开始题号</label>
        <div class="col-sm-7">
        <input class="form-control" name="start" type="text"/></div>
    </div>
	<div class="form-group">
        <label class="col-sm-5 control-label">结束题号</label>
        <div class="col-sm-7">
        <input class="form-control" name="end" type="text"/></div>
    </div>
	<input type='hidden' name='do' value='do'>
	<?php require_once("../include/set_post_key.php");?>
	<div class="form-group">
        <div class="col-sm-offset-5 col-sm-7">
            <input type="submit" class="btn btn-primary col-sm-8" value="转移"/>
        </div>
    </div>
</form>
	

